package com.lv.listener;

import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Map;

/**
 * Created by lvjilei on 2018/4/18.
 */
public class MyApplicationEnviromentPrepareListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent>{
    @Override
    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
       ConfigurableEnvironment environment =  event.getEnvironment();

       Map<String, Object> values = environment.getSystemProperties();

        for (String key : values.keySet()){
            System.out.println(key + ":" + values.get(key));
        }

    }
}
